function speeding(speeds, limit) {
  let num = 0;
  let beyondSpeed = 0;
  for (const speed of speeds) {
    if (speed > limit) {
      num++;
      beyondSpeed += speed - limit;
    }
  }
  if (!num) {
    return [0, 0];
  }
  return [num, beyondSpeed/num];
}

console.log(speeding([50, 60, 55], 60));
console.log(speeding([58, 50, 60, 55], 55));